package pl.edu.pw.MidEmu.Samples.MidasChat.UI.Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import pl.edu.pw.MidEmu.Base.Controllers.BaseController;
import pl.edu.pw.MidEmu.Samples.MidasChat.Common.Consts;
import pl.edu.pw.MidEmu.Samples.MidasChat.UI.Views.MIDASChatFrameView;

/**
 * Class representing controller for chat login frame
 * @author Mateusz Starodab
 *
 */
public class MIDASChatFrameController extends BaseController<MIDASChatFrameView> implements ActionListener
{
	@Override
	/**
	 * Mouse actions event handler
	 */
	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource() instanceof JButton)
		{
			JButton button = (JButton) e.getSource();
			if (button.getName().equals(Consts.MIDASChatFrame_btnStart))
			{
				if (getView().validate())
				{
					getView().showChatFrame();
				}
				else
				{
					getView().reportValidationError();
				}
			}
		}

	}
}
